package com.example.mobile2121606109ycg0330homework2;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText edtTxtMainName;
    private EditText edtTxtMainPSW;
    private Button btnMainLogin;
    private Button btnMainDel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        btnMainDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                edtTxtMainName.setText("");
                edtTxtMainPSW.setText("");
            }
        });
    }

    public void login(View view) {
        String name = edtTxtMainName.getText().toString();
        String psw = edtTxtMainPSW.getText().toString();
        if (name != "admin"){
            Log.i("TAG", "login:用户名错误");
        }
        if (psw != "admin"){
            Log.i("TAG", "login:密码错误");
        }
    }

    private void initView() {
        edtTxtMainName = (EditText) findViewById(R.id.edtTxtMainName);
        edtTxtMainPSW = (EditText) findViewById(R.id.edtTxtMainPSW);
        btnMainLogin = (Button) findViewById(R.id.btnMainLogin);
        btnMainDel = (Button) findViewById(R.id.btnMainDel);
    }
}